var app = getApp(),
  $ = require("../../utils/httpHelper.js");
Page({
  data: {
    nav: ["处理中", "完成"],
    currnav: 0,
    page: 1,
    pagesize: 10,
    totalpage: 0,//最大页数
    height: 0,
    nomore: true,
    status: 0,
    monlist: [],
  },
  onLoad: function (options) {
    var that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({ height: res.windowHeight })
      }
    })
    this.getData()
  },
  getData() {
    let par = {
      rd_session: app.globalData.userInfo.rd_session,
      status: this.data.status,
      page: this.data.page,
      pagesize: this.data.pagesize,
    }
    $.httpPost("draw_record", par, (data, err) => {
      this.setData({
        monlist: data.data.list,
        totalpage: data.data.total_page,
      })
    })
  },
  currrnav: function (e) {
    console.log(e)
    var currnav = e.currentTarget.dataset.index
    this.setData({
      currnav: currnav,
      page: 1,
      status: currnav
    })
    this.getData()
  },
  //滑动到底部 上拉加载
  scrollBottom: function () {
    this.data.page++
    if (this.data.page > this.data.totalpage) {
      this.setData({
        nomore: false
      })
    } else {
      let params = {
        rd_session: app.globalData.userInfo.rd_session,
        page: this.data.page,
        pagesize: this.data.pagesize,
        types: this.data.types
      }
      $.httpPost("finance_record", params, (data, err) => {
        let arr = this.data.monlist;
        for (let item of data.data.list) {
          arr.push(item);
        }
        this.setData({
          monlist: arr,
        })
      })
    }

  },
})